package com.stream;


import com.entity.User;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Author weijingchen
 * @Date 2025/6/14 17:53
 * @Version 1.0.0
 */
public class Test01 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("张三,1");
        list.add("李四,2");
        list.add("王五,3");
        list.add("赵六,4");
        list.add("孙七,5");
        list.add("周八,6");


        Stream<String> stream1 = list.stream().filter(name -> name.startsWith("张"));
        Stream<String> stream = Stream.of("张三,1", "李四,2", "王五,3", "赵六,4", "孙七,5", "周八,6");
        list.stream().map(s -> {
            String substring = s.substring( s.length()-1);
            return Integer.valueOf(substring);
        }).forEach(System.out::println);

        List<User> collect = Stream.concat(stream1, stream)
                .map(s -> new User(s.split(",")[0], Integer.parseInt(s.split(",")[1]), ""))
                .collect(Collectors.toList());

        System.out.println( collect);
        //合并两个流对象，并将集合中的元素转换成Actor对象，然后将Actor对象中的数据打印出来

        list.stream().map(Integer::parseInt).forEach(System.out::println);
    }

}
